package com.lx;

import com.lx.dao.IDeptDao;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.Reader;
import java.util.Map;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )  throws Exception
    {
        //读取Mybatis配置文件
        Reader reader = Resources.getResourceAsReader("mybatis.xml");
        //创建SqlSessionFactory
        SqlSessionFactory ssf =   new SqlSessionFactoryBuilder().build(reader);
        //创建SqlSession
        SqlSession sqlSession = ssf.openSession(true);
        //得到接口的实现类
        IDeptDao deptDao = sqlSession.getMapper(IDeptDao.class);
        
        Map<String,Object> dept = deptDao.findDept(10);

        System.out.println("dept = " + dept);
    }
}
